#!/bin/sh

# Sanity
if [ ! -e Code/BasicFilters/json/ ]; then
    echo "This script must be run for the root of SimpleITK's checkout (Utilities/BuildDocs <path to ITK-doxygen>)"
    exit 1
fi

if [ ! -e $1/Utilities/Doxygen/xml/itkImage_8h.xml ]; then
    echo "The first argument must be the root of an ITK build with XML documentation generated"
    exit 1
fi

rm -f Wrapping/PythonDocstrings.i
rm -f Wrapping/JavaDoc.i

# Find all the JSON, re-write it
for f in Code/BasicFilters/json/*.json; do
    Utilities/GenerateDocumentation.groovy $f $1 Wrapping/PythonDocstrings.i Wrapping/JavaDoc.i

    # run the python script to return to standard formatting
    Utilities/JSONInputAToInputs.py $f
done
